import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

class MyCachedNetworkImage extends StatelessWidget {
  final String imageUrl;
  final double width;
  final double height;
  final int x;
  final int y;

  const MyCachedNetworkImage({
    super.key,
    required this.imageUrl,
    this.width = 100,
    this.height = 100,
    this.x = 200,
    this.y = 200,
  });

  @override
  Widget build(BuildContext context) {
    return CachedNetworkImage(
      imageUrl: '$imageUrl?param=${x}y$y',
      width: width,
      height: height,
      fit: BoxFit.cover,
      placeholder: (context, url) => Container(
        width: width,
        height: height,
        color: Colors.grey.shade200,
        child: const Icon(Icons.music_note, color: Colors.white),
      ),
      errorWidget: (context, url, error) => Container(
        width: width,
        height: height,
        color: Colors.grey.shade300,
        child: const Icon(Icons.error),
      ),
    );
  }
}
